/**
 * Copyright 2021 nicos AG
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author Simon Petrac <spetrac@nicos-ag.com>
 * @contributor Jörg Langkau <jlangkau@nicos-ag.com>
 * @license Apache-2.0
 */

const
    util         = require('./util.js'),
    repoFolder   = util.joinPath(__dirname, '../..'),
    // The following method converts relative file- or folder-paths in the repository to absolute paths.
    absolutePath = (relativePath) => util.joinPath(repoFolder, relativePath);

module.exports = {

    // The current version of the criteria catalogue, e.g. "0.0.1".
    // Not to be confused with the version of the rendering script.
    current_version: "0.0.1",

    // An array with absolute file-paths that all get loaded as data for rendering.
    // If a folder is specified, all .ttl files in that folder will be loaded.
    // Because there are many files especially for TDS and TCS, the folder notation
    // is generally more practical. Be aware that sub-folders don't get loaded.
    ttlDataFiles: [
        absolutePath('catalog'),
        absolutePath('profiles'),

        //region >> criteria
        absolutePath('criteria'),
        absolutePath('criteria/connector'),
        absolutePath('criteria/broker'),
        absolutePath('criteria/development'),
        absolutePath('criteria/iec_62443-4-2'),
        //endregion >> criteria

        //region >> TDS
        absolutePath('specification/test/design'),
        absolutePath('specification/test/design/connector'),
        absolutePath('specification/test/design/broker'),
        absolutePath('specification/test/design/development'),
        absolutePath('specification/test/design/iec_62443-4-2'),
        //endregion >> TDS

        //region >> TCS
        absolutePath('specification/test/case'),
        absolutePath('specification/test/case/connector'),
        absolutePath('specification/test/case/broker'),
        absolutePath('specification/test/case/development'),
        absolutePath('specification/test/case/iec_62443-4-2'),
        //endregion >> TCS

        //region >> questionnaire
        absolutePath('questionnaire'),
        absolutePath('questionnaire/connector'),
        absolutePath('questionnaire/development'),
        absolutePath('questionnaire/iec_62443-4-2')
        //endregion >> questionnaire
    ],

    // An array with absolute file-paths that all get loaded as shapes for validation.
    // If a folder is specified, all .shapes.ttl files in that folder will be loaded.
    ttlShapeFiles: [
        absolutePath('model/resources/shapes')
    ],

    // An array with absolute file-paths that all get loaded as model for the ids3cm.
    // If a folder is specified, all .ttl files in that folder will be loaded.
    ttlModelFiles: [
        absolutePath('model/Ontology.ttl'),
        absolutePath('model/resources'),
        absolutePath('model/resources/Acceptance'),
        absolutePath('model/resources/CheckList'),
        absolutePath('model/resources/Function'),
        absolutePath('model/resources/meta'),
        absolutePath('model/resources/Specification'),
        absolutePath('model/resources/Specification/ComponentTestSpecification')
    ],

    // The absolute file-path for the turtle serialization output.
    ttlOutputFile: absolutePath('serializations/ids3c-co.ttl'),

    // The absolute file-path for the turtle serialization output of the model.
    ttlModelOutputFile: absolutePath('serializations/ids3cm.ttl'),

    // The absolute file-path for the json-ld serialization output.
    jsonOutputFile: absolutePath('serializations/ids3c-co.json'),

    // The absolute file-path for the json-ld serialization output of the model.
    jsonModelOutputFile: absolutePath('serializations/ids3cm.json'),

    // The absolute file-path for the shacl report file.
    shaclReportFile: absolutePath('report/ids3c-co.shacl-report.ttl'),

    // The absolute file-path for the scripted json report file.
    scriptReportFile: absolutePath('report/ids3c-co.script-report.json'),

    // A boolean indication if an invalid shacl validation should
    // cancel the rendering. Usually this is set to false.
    shaclStrictRejection: false,

    // A boolean indication if an invalid script validation should
    // cancel the rendering. Usually this is set to false.
    scriptStrictRejection: false,

    // A boolean indication if a final replacement that can't be found for
    // a particular template, should skip the rendering of that file.
    // Usually this is set to false.
    markdownSkipIfMissingFIR: false,

    // A configuration object for all languages that should get rendered.
    // The keys are the language identifiers and the value is an object with
    // a dop (=do-perform) property. This should be {'en': {dop: true}} by default.
    renderLanguages: {
        'en': {dop: true},
        'de': {dop: false}
    },

    // A configuration object for the rendering of the individual TDS markdown files.
    markdownTDS: {
        dop:           true,
        inputTemplate: absolutePath('rendering/templates/human_friendly_md/{$FIR_language}/specification/test/design/SPEC.md'),
        outputFolder:  absolutePath('human_friendly/{$FIR_language}/specification/test/design/specs/')
    },

    // A configuration object for the rendering of the individual TCS markdown files.
    markdownTCS: {
        dop:           true,
        inputTemplate: absolutePath('rendering/templates/human_friendly_md/{$FIR_language}/specification/test/case/SPEC.md'),
        outputFolder:  absolutePath('human_friendly/{$FIR_language}/specification/test/case/specs/')
    },

    // An array with configuration objects for the rendering of individual templates.
    // Those are usually the README files for the main folders, like criteria or questionnaire.
    markdownOutput: [
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/README.md'),
            outputFile:   absolutePath('human_friendly/en/README.md'),
            language:     'en'
        },
        {
            dop:          false,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/all_in_the_house.md'),
            outputFile:   absolutePath('human_friendly/en/all_in_the_house.md'),
            language:     'en'
        },
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/criteria/README.md'),
            outputFile:   absolutePath('human_friendly/en/criteria/README.md'),
            language:     'en'
        },
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/questionnaire/README.md'),
            outputFile:   absolutePath('human_friendly/en/questionnaire/README.md'),
            language:     'en'
        },
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/specification/test/case/README.md'),
            outputFile:   absolutePath('human_friendly/en/specification/test/case/README.md'),
            language:     'en'
        },
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/specification/test/design/README.md'),
            outputFile:   absolutePath('human_friendly/en/specification/test/design/README.md'),
            language:     'en'
        },
        {
            dop:          true,
            templateFile: absolutePath('rendering/templates/human_friendly_md/en/specification/test/design/Attacker_model.md'),
            outputFile:   absolutePath('human_friendly/en/specification/test/design/Attacker_model.md'),
            language:     'en'
        }
    ]

};
